package com.bd.wechat.controller;


import com.bd.wechat.core.R;
import com.bd.wechat.entity.Store;
import com.bd.wechat.entity.request.NearestRequest;
import com.bd.wechat.entity.response.map.NearestOneStoreResponse;
import com.bd.wechat.service.StoreService;
import com.bd.wechat.utils.GeoUtils;
import com.bd.wechat.utils.Location;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @menu 小程序端
 *
 * @author linhs
 * @since 2024-11-29
 */
@RestController
@RequestMapping("/wechat/store")
public class StoreController {
    @Resource
    private StoreService storeService;

    /**
     * 最近距离的N个门店
     *
     * @param nearestRequest
     * @return
     */
    @PostMapping("/nearest")
    public R<List<Store>> getNearestStore(@RequestBody NearestRequest nearestRequest) {
        return R.ok(storeService.getNearestStore(nearestRequest));
    }

    /**
     * 最近距离的1个门店
     *
     * @param nearestRequest
     * @return
     */
    @PostMapping("/nearestOne")
    public R<NearestOneStoreResponse> getnearestOneStore(@RequestBody NearestRequest nearestRequest) {
        return R.ok(storeService.getnearestOneStore(nearestRequest));
    }
}

